package com.jprocms.module.cms.dal.dataobject.accesspage;

import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jpro.framework.mybatis.core.dataobject.BaseDO;
import com.jprocms.module.cms.dal.dataobject.StatDateString;
import lombok.*;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 访问受访页面 DO
 *
 * @author jprocms
 */
@TableName("cms_access_page")
@KeySequence("cms_access_page_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库，可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@AllArgsConstructor
public class AccessPageDO extends BaseDO implements StatDateString, Serializable {
    private static final long serialVersionUID = 1L;
    /**
     * ID
     */
    @TableId
    private Long id;
    /**
     * 站点ID
     */
    private Long siteId;
    /**
     * 受访URL
     */
    private String accessUrl;
    /**
     * 访问量
     */
    private Long pvCount;
    /**
     * 访客数
     */
    private Long uvCount;
    /**
     * IP数
     */
    private Long ipCount;
    /**
     * 统计日期(yyyyMMdd)
     */
    private String dateString;
    /**
     * 类型(1:访问地址,2:入口地址)
     */
    private Integer accessType;

    public AccessPageDO() {
    }

    public AccessPageDO(String dateString, LocalDateTime date) {
        setDateString(dateString);
        setDate(date);
    }

    public void setDateString(String dateString) {
        this.dateString = dateString;
    }


    @TableField(exist = false)
    private LocalDateTime date = LocalDateTime.now();

    /**
     * 类型：访问地址
     */
    public static final Integer TYPE_VISITED_URL = 1;
    /**
     * 类型：入口地址
     */
    public static final Integer TYPE_ENTRY_URL = 2;

    @Override
    public void setDate(LocalDateTime date) {
        this.date = date;
    }
}
